package bairui.international.service.impl;

import bairui.international.model.domain.jpa.TB_ProductOrder;
import bairui.international.service.Service_ProductOrder_Generate;
import org.springframework.stereotype.Service;
import bairui.international.dao.jpa.Repository_ProductOrder;

/**
 *
 */
@Service
public class Service_ProductOrderImpl_Generate
	implements Service_ProductOrder_Generate
{

	
	@org.springframework.beans.factory.annotation.Autowired
	private Repository_ProductOrder dao;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_ProductOrderStateRecord service_ProductOrderStateRecord;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_BranchCompanyStaffRoyaltyRecord service_BranchCompanyStaffRoyaltyRecord;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_UserGradeRecord service_UserGradeRecord;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_ProductOrderItem service_ProductOrderItem;

	@org.springframework.beans.factory.annotation.Autowired
	private bairui.international.service.Service_BranchCompanyMoneyRecord service_BranchCompanyMoneyRecord;



	
	
	
	/**
	 * deleteById
	 */
	public void deleteById(
		@com.sh_lianjing.annotation.ParameterName("id") @lombok.NonNull Long id
	) throws Exception {
		TB_ProductOrder bean = getDao().findById(id).get();
		// productOrderStateRecords
		java.util.List<bairui.international.model.domain.jpa.TB_ProductOrderStateRecord> productOrderStateRecords = service_ProductOrderStateRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!productOrderStateRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ProductOrderStateRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_ProductOrderStateRecord item : productOrderStateRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "productOrderStateRecords", str);
		}
		// branchCompanyStaffRoyaltyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord> branchCompanyStaffRoyaltyRecords = service_BranchCompanyStaffRoyaltyRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyStaffRoyaltyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyStaffRoyaltyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord item : branchCompanyStaffRoyaltyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyStaffRoyaltyRecords", str);
		}
		// userGradeRecords
		java.util.List<bairui.international.model.domain.jpa.TB_UserGradeRecord> userGradeRecords = service_UserGradeRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!userGradeRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_UserGradeRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_UserGradeRecord item : userGradeRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "userGradeRecords", str);
		}
		// productOrderItems
		java.util.List<bairui.international.model.domain.jpa.TB_ProductOrderItem> productOrderItems = service_ProductOrderItem.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!productOrderItems.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ProductOrderItem.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_ProductOrderItem item : productOrderItems){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "productOrderItems", str);
		}
		// branchCompanyMoneyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord> branchCompanyMoneyRecords = service_BranchCompanyMoneyRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyMoneyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyMoneyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord item : branchCompanyMoneyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyMoneyRecords", str);
		}
		// userInfo
		bairui.international.model.domain.jpa.TB_UserInfo userInfo = bean.getUserInfo();
		if(null != userInfo){
		}
		// goodsInfo
		bairui.international.model.domain.jpa.TB_GoodsInfo goodsInfo = bean.getGoodsInfo();
		if(null != goodsInfo){
		}
		// electronicTicket
		bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket = bean.getElectronicTicket();
		if(null != electronicTicket){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ElectronicTicket.Comment+":[" + electronicTicket.toString() + "])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "electronicTicket", str);
		}
		getDao().deleteById(id);
	}
	/**
	 * findDeleteById
	 */
	public TB_ProductOrder findDeleteById(
		@com.sh_lianjing.annotation.ParameterName("id") @lombok.NonNull Long id
	) throws Exception {
		TB_ProductOrder bean = getDao().findById(id).get();
		// productOrderStateRecords
		java.util.List<bairui.international.model.domain.jpa.TB_ProductOrderStateRecord> productOrderStateRecords = service_ProductOrderStateRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!productOrderStateRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ProductOrderStateRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_ProductOrderStateRecord item : productOrderStateRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "productOrderStateRecords", str);
		}
		// branchCompanyStaffRoyaltyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord> branchCompanyStaffRoyaltyRecords = service_BranchCompanyStaffRoyaltyRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyStaffRoyaltyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyStaffRoyaltyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord item : branchCompanyStaffRoyaltyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyStaffRoyaltyRecords", str);
		}
		// userGradeRecords
		java.util.List<bairui.international.model.domain.jpa.TB_UserGradeRecord> userGradeRecords = service_UserGradeRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!userGradeRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_UserGradeRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_UserGradeRecord item : userGradeRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "userGradeRecords", str);
		}
		// productOrderItems
		java.util.List<bairui.international.model.domain.jpa.TB_ProductOrderItem> productOrderItems = service_ProductOrderItem.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!productOrderItems.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ProductOrderItem.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_ProductOrderItem item : productOrderItems){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "productOrderItems", str);
		}
		// branchCompanyMoneyRecords
		java.util.List<bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord> branchCompanyMoneyRecords = service_BranchCompanyMoneyRecord.page(it->it.productOrder.eq(bean), org.springframework.data.domain.PageRequest.of(0, 3)).getContent();
		
		if(!branchCompanyMoneyRecords.isEmpty()){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_BranchCompanyMoneyRecord.Comment+":[";
			boolean startFlag = true;
			for(bairui.international.model.domain.jpa.TB_BranchCompanyMoneyRecord item : branchCompanyMoneyRecords){
				if(!startFlag){
					str += ", ";
				}
				startFlag = false;
				str += item.toString();
			}
			str += ", ...])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "branchCompanyMoneyRecords", str);
		}
		// userInfo
		bairui.international.model.domain.jpa.TB_UserInfo userInfo = bean.getUserInfo();
		if(null != userInfo){
		}
		// goodsInfo
		bairui.international.model.domain.jpa.TB_GoodsInfo goodsInfo = bean.getGoodsInfo();
		if(null != goodsInfo){
		}
		// electronicTicket
		bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket = bean.getElectronicTicket();
		if(null != electronicTicket){
			String str = "("+bean.toString()+")正在被("+bairui.international.model.domain.jpa.TTB_ElectronicTicket.Comment+":[" + electronicTicket.toString() + "])使用";
			throw new com.lianjing.sh.validate.spring.exception.ValidateObjectException("", "electronicTicket", str);
		}
		getDao().deleteById(id);
		return bean;
	}
	/**
	 * deleteByIds
	 */
	public void deleteByIds(
		@com.sh_lianjing.annotation.ParameterName("ids") @lombok.NonNull Long ... ids
	) throws Exception {
		deleteByIds(java.util.Arrays.asList(ids));
	}
	
	/**
	 * deleteByIds
	 */
	public void deleteByIds(
		@com.sh_lianjing.annotation.ParameterName("ids") @lombok.NonNull java.util.List<Long> ids
	) throws Exception {
		for(Long id : ids){
			deleteById(id);
		}
	}
		






	/**
	 * getDao()
	 */
	public bairui.international.dao.jpa.Repository_ProductOrder getDao() {
		return dao;
	}

}
